Dynomotion

Group: DynoMotion Message: 9816 From: ricochetproducts Date: 7/20/2014
Subject: MPG smooth hardware

Hi Tom. I am trying to get this program to run . Should I be using this code in it's own thread or should I nest it with my init file?  I have the Buttons wired to my Konnect board and they are working. and I am getting the signal to the Kanalog Diff input 5 but nothing is working. I am sure that I am missing something but I don't know what. 

Any help is appreciated.


Thanks, Steve

  @@attachment@@
Group: DynoMotion Message: 9817 From: Tom Kerekes Date: 7/20/2014
Subject: Re: MPG smooth hardware [2 Attachments]
Hi Steve,

It should work either way but it should be eventually merged into one forever loop into your Init C file so only running Init will service everything.

I think you win the prize for the biggest Init file I've seen.  Nice work.

When you turn the MPG does the Position of Axis 5 change on the KMotion Axis Screen?

The ENABLE_MPG bit 1055 is programmed to be active low.  Is it unchecked on the Digital IO Screen?

When you select X is bit 1048 checked?

When you select Factor=1 is bit 1052 checked?

BTW there is now a JOB_ACTIVE status that can be used to disable the MPG while a Job is running.  You might add in that condition with:

        if (ReadBit(ENABLE_MPG) || JOB_ACTIVE) // if button pressed or Job running ignore the encoder.

BTW we have an issue with Kanalog ADC7 where it doesn't have the full 12 bits of resolution that we have yet to be able to fix.  Consider using a different ADC channel if possible.

HTH
Regards
TK



From: "steveklemp@... [DynoMotion]" <DynoMotion@yahoogroups.com>
To: DynoMotion@yahoogroups.com
Sent: Sunday, July 20, 2014 8:25 AM
Subject: [DynoMotion] MPG smooth hardware [2 Attachments]

 
[Attachment(s) from steveklemp@... [DynoMotion] included below]
Hi Tom. I am trying to get this program to run . Should I be using this code in it's own thread or should I nest it with my init file?  I have the Buttons wired to my Konnect board and they are working. and I am getting the signal to the Kanalog Diff input 5 but nothing is working. I am sure that I am missing something but I don't know what. 
Any help is appreciated.

Thanks, Steve


Group: DynoMotion Message: 9865 From: Steve Klemp Date: 7/27/2014
Subject: Re: MPG smooth hardware
Hi Tom,   I still don't have this up an running.  
In response to your questions:

When you turn the MPG does the Position of Axis 5 change on the KMotion Axis Screen? No,  I don't see any change on this screen 

The ENABLE_MPG bit 1055 is programmed to be active low.  Is it unchecked on the Digital IO Screen? it is unchecked

When you select X is bit 1048 checked? yes this is checked when I select X

When you select Factor=1 is bit 1052 checked? this also gets a check when I select Factor=1
--------------------------------------------------------------------------------------------------------------

I have change everything tho channel 4 (ch4)  I still don't see a change of position on Axis 4 KMotion Axis Screen

and I changed ENABLE_MPG bit 1055 to be active High. (!ReadBit(ENABLE_MPG))  


A question that I have is in the example code:

EnableAxisDest(0,0);

EnableAxisDest(0,ch4->Position);
DefineCoordSystem(0,-1,-1,-1);

Will this need to be edited to make it work for a three Axis system?

Also does this code need to be changed for a three Axis system?
Is this just sample code or is this what is needed for the MPG?

ch4->InputMode=ENCODER_MODE;
ch4->OutputMode=CL_STEP_DIR_MODE;
ch4->Vel=10000.000000;
ch4->Accel=60000.000000;
ch4->Jerk=10000000.000000;
ch4->P=0.000000;
ch4->I=0.015000;
ch4->D=0.000000;
ch4->FFAccel=0.000000;
ch4->FFVel=0.000000;
ch4->MaxI=200.000000;
ch4->MaxErr=200.000000;
ch4->MaxOutput=2000.000000;
ch4->DeadBandGain=1.000000;
ch4->DeadBandRange=0.000000;
ch4->InputChan0=0;
ch4->InputChan1=0;
ch4->OutputChan0=12;
ch4->OutputChan1=0;
ch4->LimitSwitchOptions=0x0;
ch4->InputGain0=-2.500000;
ch4->InputOffset0=0.000000;
ch4->OutputGain=1.000000;
ch4->OutputOffset=0.000000;
ch4->SlaveGain=1.00000;
ch4->BacklashMode=BACKLASH_OFF;
ch4->BacklashAmount=0.00000;
ch4->BacklashRate=0.00000;
ch4->invDistPerCycle=1.000000;
ch4->Lead=0.000000;
ch4->MaxFollowingError=100000.000000;
ch4->StepperAmplitude=250.000000;

ch4->iir[0].B0=1.000000;
ch4->iir[0].B1=0.000000;
ch4->iir[0].B2=0.000000;
ch4->iir[0].A1=0.000000;
ch4->iir[0].A2=0.000000;

ch4->iir[1].B0=1.000000;
ch4->iir[1].B1=0.000000;
ch4->iir[1].B2=0.000000;
ch4->iir[1].A1=0.000000;
ch4->iir[1].A2=0.000000;

ch4->iir[2].B0=1.000000;
ch4->iir[2].B1=0.000000;
ch4->iir[2].B2=0.000000;
ch4->iir[2].A1=0.000000;
ch4->iir[2].A2=0.00000;
    
If theses questions sound dumb, I do apologize,  I am not a C programmer I am more of a cut/paste Guy.

Am I reading this code correctly?

if (ReadBit(SELECTX))  // is x selected    In the Example code Where "Axis" is, as in  if (Axis != LastAxis ||
Does this mean X Axis 

Sorry I am just trying to get my head wrapped around this.

As Always, Thanks for all your Help!

Steve





 
.....Steve
            
 


On Sunday, July 20, 2014 11:21 AM, "Tom Kerekes tk@... [DynoMotion]" <DynoMotion@yahoogroups.com> wrote:


 
Hi Steve,

It should work either way but it should be eventually merged into one forever loop into your Init C file so only running Init will service everything.

I think you win the prize for the biggest Init file I've seen.  Nice work.

When you turn the MPG does the Position of Axis 5 change on the KMotion Axis Screen?

The ENABLE_MPG bit 1055 is programmed to be active low.  Is it unchecked on the Digital IO Screen?

When you select X is bit 1048 checked?

When you select Factor=1 is bit 1052 checked?

BTW there is now a JOB_ACTIVE status that can be used to disable the MPG while a Job is running.  You might add in that condition with:

        if (ReadBit(ENABLE_MPG) || JOB_ACTIVE) // if button pressed or Job running ignore the encoder.

BTW we have an issue with Kanalog ADC7 where it doesn't have the full 12 bits of resolution that we have yet to be able to fix.  Consider using a different ADC channel if possible.

HTH
Regards
TK



From: "steveklemp@... [DynoMotion]" <DynoMotion@yahoogroups.com>
To: DynoMotion@yahoogroups.com
Sent: Sunday, July 20, 2014 8:25 AM
Subject: [DynoMotion] MPG smooth hardware [2 Attachments]

 
[Attachment(s) from steveklemp@... [DynoMotion] included below]
Hi Tom. I am trying to get this program to run . Should I be using this code in it's own thread or should I nest it with my init file?  I have the Buttons wired to my Konnect board and they are working. and I am getting the signal to the Kanalog Diff input 5 but nothing is working. I am sure that I am missing something but I don't know what. 
Any help is appreciated.

Thanks, Steve




Group: DynoMotion Message: 9866 From: Tom Kerekes Date: 7/27/2014
Subject: Re: MPG smooth hardware
Hi Steve,

It looks like you don't have Axis Channel #4 configured to use Encoder #4 but rather Encoder #0.  Configure

ch4->InputChan0 = 4;

Then see if Axis Channel #4's position changes when the MPG moves.

If you are using Axis Channel #4 only for the MPG Encoder input functionality there is no need to enable the Axis.  The axis will still track the encoder position whether or not the Output is enabled.  Actually this is enabling axis #0 to axis #4's position.   So remove this:

EnableAxisDest(0,ch4->Position);

A straightforward 3 axis system would be configured as:

DefineCoordSystem(0,1,2,-1);

Regarding "Axis" in the MPG C Program: this is a variable that is set to the currently selected axis.  It can have a value of any axis.

HTH
Regards
TK




From: "Steve Klemp steveklemp@... [DynoMotion]" <DynoMotion@yahoogroups.com>
To: "DynoMotion@yahoogroups.com" <DynoMotion@yahoogroups.com>
Sent: Sunday, July 27, 2014 7:42 AM
Subject: Re: [DynoMotion] MPG smooth hardware

 
Hi Tom,   I still don't have this up an running.  
In response to your questions:

When you turn the MPG does the Position of Axis 5 change on the KMotion Axis Screen? No,  I don't see any change on this screen 

The ENABLE_MPG bit 1055 is programmed to be active low.  Is it unchecked on the Digital IO Screen? it is unchecked

When you select X is bit 1048 checked? yes this is checked when I select X

When you select Factor=1 is bit 1052 checked? this also gets a check when I select Factor=1
--------------------------------------------------------------------------------------------------------------

I have change everything tho channel 4 (ch4)  I still don't see a change of position on Axis 4 KMotion Axis Screen

and I changed ENABLE_MPG bit 1055 to be active High. (!ReadBit(ENABLE_MPG))  


A question that I have is in the example code:

EnableAxisDest(0,0);

EnableAxisDest(0,ch4->Position);
DefineCoordSystem(0,-1,-1,-1);

Will this need to be edited to make it work for a three Axis system?

Also does this code need to be changed for a three Axis system?
Is this just sample code or is this what is needed for the MPG?

ch4->InputMode=ENCODER_MODE;
ch4->OutputMode=CL_STEP_DIR_MODE;
ch4->Vel=10000.000000;
ch4->Accel=60000.000000;
ch4->Jerk=10000000.000000;
ch4->P=0.000000;
ch4->I=0.015000;
ch4->D=0.000000;
ch4->FFAccel=0.000000;
ch4->FFVel=0.000000;
ch4->MaxI=200.000000;
ch4->MaxErr=200.000000;
ch4->MaxOutput=2000.000000;
ch4->DeadBandGain=1.000000;
ch4->DeadBandRange=0.000000;
ch4->InputChan0=0;
ch4->InputChan1=0;
ch4->OutputChan0=12;
ch4->OutputChan1=0;
ch4->LimitSwitchOptions=0x0;
ch4->InputGain0=-2.500000;
ch4->InputOffset0=0.000000;
ch4->OutputGain=1.000000;
ch4->OutputOffset=0.000000;
ch4->SlaveGain=1.00000;
ch4->BacklashMode=BACKLASH_OFF;
ch4->BacklashAmount=0.00000;
ch4->BacklashRate=0.00000;
ch4->invDistPerCycle=1.000000;
ch4->Lead=0.000000;
ch4->MaxFollowingError=100000.000000;
ch4->StepperAmplitude=250.000000;

ch4->iir[0].B0=1.000000;
ch4->iir[0].B1=0.000000;
ch4->iir[0].B2=0.000000;
ch4->iir[0].A1=0.000000;
ch4->iir[0].A2=0.000000;

ch4->iir[1].B0=1.000000;
ch4->iir[1].B1=0.000000;
ch4->iir[1].B2=0.000000;
ch4->iir[1].A1=0.000000;
ch4->iir[1].A2=0.000000;

ch4->iir[2].B0=1.000000;
ch4->iir[2].B1=0.000000;
ch4->iir[2].B2=0.000000;
ch4->iir[2].A1=0.000000;
ch4->iir[2].A2=0.00000;
    
If theses questions sound dumb, I do apologize,  I am not a C programmer I am more of a cut/paste Guy.

Am I reading this code correctly?

if (ReadBit(SELECTX))  // is x selected    In the Example code Where "Axis" is, as in  if (Axis != LastAxis ||
Does this mean X Axis 

Sorry I am just trying to get my head wrapped around this.

As Always, Thanks for all your Help!

Steve





 
.....Steve
            
 


On Sunday, July 20, 2014 11:21 AM, "Tom Kerekes tk@... [DynoMotion]" <DynoMotion@yahoogroups.com> wrote:


 
Hi Steve,

It should work either way but it should be eventually merged into one forever loop into your Init C file so only running Init will service everything.

I think you win the prize for the biggest Init file I've seen.  Nice work.

When you turn the MPG does the Position of Axis 5 change on the KMotion Axis Screen?

The ENABLE_MPG bit 1055 is programmed to be active low.  Is it unchecked on the Digital IO Screen?

When you select X is bit 1048 checked?

When you select Factor=1 is bit 1052 checked?

BTW there is now a JOB_ACTIVE status that can be used to disable the MPG while a Job is running.  You might add in that condition with:

        if (ReadBit(ENABLE_MPG) || JOB_ACTIVE) // if button pressed or Job running ignore the encoder.

BTW we have an issue with Kanalog ADC7 where it doesn't have the full 12 bits of resolution that we have yet to be able to fix.  Consider using a different ADC channel if possible.

HTH
Regards
TK



From: "steveklemp@... [DynoMotion]" <DynoMotion@yahoogroups.com>
To: DynoMotion@yahoogroups.com
Sent: Sunday, July 20, 2014 8:25 AM
Subject: [DynoMotion] MPG smooth hardware [2 Attachments]

 
[Attachment(s) from steveklemp@... [DynoMotion] included below]
Hi Tom. I am trying to get this program to run . Should I be using this code in it's own thread or should I nest it with my init file?  I have the Buttons wired to my Konnect board and they are working. and I am getting the signal to the Kanalog Diff input 5 but nothing is working. I am sure that I am missing something but I don't know what. 
Any help is appreciated.

Thanks, Steve






Group: DynoMotion Message: 9869 From: Steve Klemp Date: 7/27/2014
Subject: Re: MPG smooth hardware
Tom, thank you for your time. I will give it a try and let you know what I find.
Thanks for all you do!

Group: DynoMotion Message: 9898 From: Steve Klemp Date: 8/3/2014
Subject: Re: MPG smooth hardware
Hi Tom,  I finally got a chance to work on my machine again.  I made the changes that you had sugestested. Now Axis Channel #4's position changes when the MPG moves. I do get all te defined switch inputs. I did verify that. I still cannot get an output (Axis) to move.  I am sure that I am missing something very basic but I cant see it. Here is my C program.
I am questioning this, 
ch4->OutputChan0=12;  is this suppose to be =12 ? 
 
#include "KMotionDef.h"
// Example Init program that includes "smooth" MPG motion example
// which makes use of the exponential motion command.
#define MPG_INPUT_AXIS 4
#define TAU 0.08 // smoothness factor (Low Pass Time constant seconds)
#define FINAL_TIME 1.0 // Set final dest after this amount of time with no change
#define ENABLE_MPG 1055
#define SELECTX 1048
#define SELECTY 1049
#define SELECTZ 1050
#define FACTOR1 1052
#define FACTOR10 1053
#define FACTOR100 1054
main()
{
     int Change1, NewPos, Pos;
     int InMotion=FALSE,Axis,LastAxis=-1;
     double LastChangeTime=0,Target,Factor=0;
 
     ch4->InputMode=ENCODER_MODE;
     ch4->OutputMode=CL_STEP_DIR_MODE;
     ch4->Vel=10000.000000;
     ch4->Accel=60000.000000;
     ch4->Jerk=10000000.000000;
     ch4->P=0.000000;
     ch4->I=0.015000;
     ch4->D=0.000000;
     ch4->FFAccel=0.000000;
     ch4->FFVel=0.000000;
     ch4->MaxI=200.000000;
     ch4->MaxErr=200.000000;
     ch4->M axOutput=2000.000000;
     ch4->DeadBandGain=1.000000;
     ch4->DeadBandRange=0.000000;
     ch4->InputChan0=4;
     ch4->InputChan1=0;
     ch4->OutputChan0=12;
     ch4->OutputChan1=0;
     ch4->LimitSwitchOptions=0x0;
     ch4->InputGain0=-2.500000;
     ch4->InputOffset0=0.000000;
     ch4->OutputGain=1.000000;
     ch4->OutputOffset=0.000000;
     ch4->SlaveGain=1.00000;
     ch4->Backl ashMode=BACKLASH_OFF;
     ch4->BacklashAmount=0.00000;
     ch4->BacklashRate=0.00000;
     ch4->invDistPerCycle=1.000000;
     ch4->Lead=0.000000;
     ch4->MaxFollowingError=100000.000000;
     ch4->StepperAmplitude=250.000000;
     ch4->iir[0].B0=1.000000;
     ch4->iir[0].B1=0.000000;
     ch4->iir[0].B2=0.000000;
     ch4->iir[0].A1=0.000000;
     ch4->iir[0].A2=0.000000;
     ch4->iir[1].B 0=1.000000;
     ch4->iir[1].B1=0.000000;
     ch4->iir[1].B2=0.000000;
     ch4->iir[1].A1=0.000000;
     ch4->iir[1].A2=0.000000;
     ch4->iir[2].B0=1.000000;
     ch4->iir[2].B1=0.000000;
     ch4->iir[2].B2=0.000000;
     ch4->iir[2].A1=0.000000;
     ch4->iir[2].A2=0.00000;
    
 
     DefineCoordSystem(0,1,2,-1);
 
     Pos = chan[MPG_INPUT_AXIS].Position;
     for (;;)
     {
          NewPos = chan[MPG_INPUT_AXIS].Position;
          Change1 = NewPos - Pos;
          Pos = NewPos;
          if (ReadBit(ENABLE_MPG)) // if button pressed ignore the encoder.
          Change1 = 0;
          else if (ReadBit(FACTOR1))  // is X1 selected?
          Factor = 2;
          else if (ReadBit(FACTOR10))  // is X10 selected?
          Factor = 20;
          else if (ReadBit(FACTOR100))  // is X100 selected?
          Factor = 200;
          else                   
          Factor = 0.0;
          if (ReadBit(SELECTX))  // is x selected?
          Axis=0;
          else if (ReadBit(SELECTY))  // is y selected?
          Axis=1;
          else if (ReadBit(SELECTZ))  // is z selected?
          Axis=2;
 
          // check if the Axis just changed or we have been 
          // converging to the target for a long time

          if (Axis != LastAxis || 
          (InMotion && Time_sec() > LastChangeTime+FINAL_TIME))
          
{
          if (InMotion)
          Move(LastAxis,Target);  //finalize any motion
 
          LastAxis = Axis;
          InMotion = FALSE;
          }
  
         if (Change1) // did we move?
         {
         if (!InMotion) Target = chan[Axis].Dest;
         Target += Change1 * Factor;
         MoveExp(Axis,Target,TAU);  // note: contains a WaitNextTimeSlice
         LastChangeTime = Time_sec();
         InMotion=TRUE;
         }
         else
        {
        WaitNextTimeSlice();
        }  
 } 
        return 0;
}
 
 
Looking forward to your response
.....Steve
            
 


On Sunday, July 27, 2014 6:36 PM, "Steve Klemp steveklemp@... [DynoMotion]" <DynoMotion@yahoogroups.com> wrote:


 
Tom, thank you for your time. I will give it a try and let you know what I find.
Thanks for all you do!

From: Tom Kerekes tk@... [DynoMotion] <DynoMotion@yahoogroups.com>;
To: DynoMotion@yahoogroups.com <DynoMotion@yahoogroups.com>;
Subject: Re: [DynoMotion] MPG smooth hardware
Sent: Sun, Jul 27, 2014 3:23:46 PM

 
Hi Steve,

It looks like you don't have Axis Channel #4 configured to use Encoder #4 but rather Encoder #0.  Configure

ch4->InputChan0 = 4;

Then see if Axis Channel #4's position changes when the MPG moves.

If you are using Axis Channel #4 only for the MPG Encoder input functionality there is no need to enable the Axis.  The axis will still track the encoder position whether or not the Output is enabled.  Actually this is enabling axis #0 to axis #4's position.   So remove this:

EnableAxisDest(0,ch4->Position);

A straightforward 3 axis system would be configured as:

DefineCoordSystem(0,1,2,-1);

Regarding "Axis" in the MPG C Program: this is a variable that is set to the currently selected axis.  It can have a value of any axis.

HTH
Regards
TK



From: "Steve Klemp steveklemp@... [DynoMotion]" <DynoMotion@yahoogroups.com>
To: "DynoMotion@yahoogroups.com" <DynoMotion@yahoogroups.com>
Sent: Sunday, July 27, 2014 7:42 AM
Subject: Re: [DynoMotion] MPG smooth hardware

 
Hi Tom,   I still don't have this up an running.  
In response to your questions:

When you turn the MPG does the Position of Axis 5 change on the KMotion Axis Screen? No,  I don't see any change on this screen 

The ENABLE_MPG bit 1055 is programmed to be active low.  Is it unchecked on the Digital IO Screen? it is unchecked

When you select X is bit 1048 checked? yes this is checked when I select X

When you select Factor=1 is bit 1052 checked? this also gets a check when I select Factor=1
--------------------------------------------------------------------------------------------------------------

I have change everything tho channel 4 (ch4)  I still don't see a change of position on Axis 4 KMotion Axis Screen

and I changed ENABLE_MPG bit 1055 to be active High. (!ReadBit(ENABLE_MPG))  


A question that I have is in the example code:

EnableAxisDest(0,0);

EnableAxisDest(0,ch4->Position);
DefineCoordSystem(0,-1,-1,-1);

Will this need to be edited to make it work for a three Axis system?

Also does this code need to be changed for a three Axis system?
Is this just sample code or is this what is needed for the MPG?

ch4->InputMode=ENCODER_MODE;
ch4->OutputMode=CL_STEP_DIR_MODE;
ch4->Vel=10000.000000;
ch4->Accel=60000.000000;
ch4->Jerk=10000000.000000;
ch4->P=0.000000;
ch4->I=0.015000;
ch4->D=0.000000;
ch4->FFAccel=0.000000;
ch4->FFVel=0.000000;
ch4->MaxI=200.000000;
ch4->MaxErr=200.000000;
ch4->MaxOutput=2000.000000;
ch4->DeadBandGain=1.000000;
ch4->DeadBandRange=0.000000;
ch4->InputChan0=0;
ch4->InputChan1=0;
ch4->OutputChan0=12;
ch4->OutputChan1=0;
ch4->LimitSwitchOptions=0x0;
ch4->InputGain0=-2.500000;
ch4->InputOffset0=0.000000;
ch4->OutputGain=1.000000;
ch4->OutputOffset=0.000000;
ch4->SlaveGain=1.00000;
ch4->BacklashMode=BACKLASH_OFF;
ch4->BacklashAmount=0.00000;
ch4->BacklashRate=0.00000;
ch4->invDistPerCycle=1.000000;
ch4->Lead=0.000000;
ch4->MaxFollowingError=100000.000000;
ch4->StepperAmplitude=250.000000;

ch4->iir[0].B0=1.000000;
ch4->iir[0].B1=0.000000;
ch4->iir[0].B2=0.000000;
ch4->iir[0].A1=0.000000;
ch4->iir[0].A2=0.000000;

ch4->iir[1].B0=1.000000;
ch4->iir[1].B1=0.000000;
ch4->iir[1].B2=0.000000;
ch4->iir[1].A1=0.000000;
ch4->iir[1].A2=0.000000;

ch4->iir[2].B0=1.000000;
ch4->iir[2].B1=0.000000;
ch4->iir[2].B2=0.000000;
ch4->iir[2].A1=0.000000;
ch4->iir[2].A2=0.00000;
    
If theses questions sound dumb, I do apologize,  I am not a C programmer I am more of a cut/paste Guy.

Am I reading this code correctly?

if (ReadBit(SELECTX))  // is x selected    In the Example code Where "Axis" is, as in  if (Axis != LastAxis ||
Does this mean X Axis 

Sorry I am just trying to get my head wrapped around this.

As Always, Thanks for all your Help!

Steve





 
.....Steve
            
 


On Sunday, July 20, 2014 11:21 AM, "Tom Kerekes tk@... [DynoMotion]" <DynoMotion@yahoogroups.com> wrote:


 
Hi Steve,

It should work either way but it should be eventually merged into one forever loop into your Init C file so only running Init will service everything.

I think you win the prize for the biggest Init file I've seen.  Nice work.

When you turn the MPG does the Position of Axis 5 change on the KMotion Axis Screen?

The ENABLE_MPG bit 1055 is programmed to be active low.  Is it unchecked on the Digital IO Screen?

When you select X is bit 1048 checked?

When you select Factor=1 is bit 1052 checked?

BTW there is now a JOB_ACTIVE status that can be used to disable the MPG while a Job is running.  You might add in that condition with:

        if (ReadBit(ENABLE_MPG) || JOB_ACTIVE) // if button pressed or Job running ignore the encoder.

BTW we have an issue with Kanalog ADC7 where it doesn't have the full 12 bits of resolution that we have yet to be able to fix.  Consider using a different ADC channel if possible.

HTH
Regards
TK


From: "steveklemp@... [DynoMotion]" <DynoMotion@yahoogroups.com>
To: DynoMotion@yahoogroups.com
Sent: Sunday, July 20, 2014 8:25 AM
Subject: [DynoMotion] MPG smooth hardware [2 Attachments]

 
[Attachment(s) from steveklemp@... [DynoMotion] included below]
Hi Tom. I am trying to get this program to run . Should I be using this code in it's own thread or should I nest it with my init file?  I have the Buttons wired to my Konnect board and they are working. and I am getting the signal to the Kanalog Diff input 5 but nothing is working. I am sure that I am missing something but I don't know what. 
Any help is appreciated.

Thanks, Steve








Group: DynoMotion Message: 9899 From: TK Date: 8/3/2014
Subject: Re: MPG smooth hardware
Hi Steve,

Can you explain how you tested the input bits?  What were the states of all the inputs when you tested?

The Output Channels don't matter. We are not enabling axis 4 to output anything. We are only using the encoder input. 

This MPG code is just commanding one of the axis to move. So the axis to move must be configured, enabled, and capable to move. Are you able to move the axis without using the MPG?  Such as a MoveRel0=1000 on the Console Screen?

Regards
TK

On Aug 3, 2014, at 4:42 PM, "Steve Klemp steveklemp@... [DynoMotion]" <DynoMotion@yahoogroups.com> wrote:

 

Hi Tom,  I finally got a chance to work on my machine again.  I made the changes that you had sugestested. Now Axis Channel #4's position changes when the MPG moves. I do get all te defined switch inputs. I did verify that. I still cannot get an output (Axis) to move.  I am sure that I am missing something very basic but I cant see it. Here is my C program.
I am questioning this, 
ch4->OutputChan0=12;  is this suppose to be =12 ? 
 
#include "KMotionDef.h"
// Example Init program that includes "smooth" MPG motion example
// which makes use of the exponential motion command.
#define MPG_INPUT_AXIS 4
#define TAU 0.08 // smoothness factor (Low Pass Time constant seconds)
#define FINAL_TIME 1.0 // Set final dest after this amount of time with no change
#define ENABLE_MPG 1055
#define SELECTX 1048
#define SELECTY 1049
#define SELECTZ 1050
#define FACTOR1 1052
#define FACTOR10 1053
#define FACTOR100 1054
main()
{
     int Change1, NewPos, Pos;
     int InMotion=FALSE,Axis,LastAxis=-1;
     double LastChangeTime=0,Target,Factor=0;
 
     ch4->InputMode=ENCODER_MODE;
     ch4->OutputMode=CL_STEP_DIR_MODE;
     ch4->Vel=10000.000000;
     ch4->Accel=60000.000000;
     ch4->Jerk=10000000.000000;
     ch4->P=0.000000;
     ch4->I=0.015000;
     ch4->D=0.000000;
     ch4->FFAccel=0.000000;
     ch4->FFVel=0.000000;
     ch4->MaxI=200.000000;
     ch4->MaxErr=200.000000;
     ch4->M axOutput=2000.000000;
     ch4->DeadBandGain=1.000000;
     ch4->DeadBandRange=0.000000;
     ch4->InputChan0=4;
     ch4->InputChan1=0;
     ch4->OutputChan0=12;
     ch4->OutputChan1=0;
     ch4->LimitSwitchOptions=0x0;
     ch4->InputGain0=-2.500000;
     ch4->InputOffset0=0.000000;
     ch4->OutputGain=1.000000;
     ch4->OutputOffset=0.000000;
     ch4->SlaveGain=1.00000;
     ch4->Backl ashMode=BACKLASH_OFF;
     ch4->BacklashAmount=0.00000;
     ch4->BacklashRate=0.00000;
     ch4->invDistPerCycle=1.000000;
     ch4->Lead=0.000000;
     ch4->MaxFollowingError=100000.000000;
     ch4->StepperAmplitude=250.000000;
     ch4->iir[0].B0=1.000000;
     ch4->iir[0].B1=0.000000;
     ch4->iir[0].B2=0.000000;
     ch4->iir[0].A1=0.000000;
     ch4->iir[0].A2=0.000000;
     ch4->iir[1].B 0=1.000000;
     ch4->iir[1].B1=0.000000;
     ch4->iir[1].B2=0.000000;
     ch4->iir[1].A1=0.000000;
     ch4->iir[1].A2=0.000000;
     ch4->iir[2].B0=1.000000;
     ch4->iir[2].B1=0.000000;
     ch4->iir[2].B2=0.000000;
     ch4->iir[2].A1=0.000000;
     ch4->iir[2].A2=0.00000;
    
 
     DefineCoordSystem(0,1,2,-1);
 
     Pos = chan[MPG_INPUT_AXIS].Position;
     for (;;)
     {
          NewPos = chan[MPG_INPUT_AXIS].Position;
          Change1 = NewPos - Pos;
          Pos = NewPos;
          if (ReadBit(ENABLE_MPG)) // if button pressed ignore the encoder.
          Change1 = 0;
          else if (ReadBit(FACTOR1))  // is X1 selected?
          Factor = 2;
          else if (ReadBit(FACTOR10))  // is X10 selected?
          Factor = 20;
          else if (ReadBit(FACTOR100))  // is X100 selected?
          Factor = 200;
          else                   
          Factor = 0.0;
          if (ReadBit(SELECTX))  // is x selected?
          Axis=0;
          else if (ReadBit(SELECTY))  // is y selected?
          Axis=1;
          else if (ReadBit(SELECTZ))  // is z selected?
          Axis=2;
 
          // check if the Axis just changed or we have been 
          // converging to the target for a long time

          if (Axis != LastAxis || 
          (InMotion && Time_sec() > LastChangeTime+FINAL_TIME))
          
{
          if (InMotion)
          Move(LastAxis,Target);  //finalize any motion
 
          LastAxis = Axis;
          InMotion = FALSE;
          }
  
         if (Change1) // did we move?
         {
         if (!InMotion) Target = chan[Axis].Dest;
         Target += Change1 * Factor;
         MoveExp(Axis,Target,TAU);  // note: contains a WaitNextTimeSlice
         LastChangeTime = Time_sec();
         InMotion=TRUE;
         }
         else
        {
        WaitNextTimeSlice();
        }  
 } 
        return 0;
}
 
 
Looking forward to your response
.....Steve
            
 


On Sunday, July 27, 2014 6:36 PM, "Steve Klemp steveklemp@... [DynoMotion]" <DynoMotion@yahoogroups.com> wrote:


 
Tom, thank you for your time. I will give it a try and let you know what I find.
Thanks for all you do!

From: Tom Kerekes tk@... [DynoMotion] <DynoMotion@yahoogroups.com>;
To: DynoMotion@yahoogroups.com <DynoMotion@yahoogroups.com>;
Subject: Re: [DynoMotion] MPG smooth hardware
Sent: Sun, Jul 27, 2014 3:23:46 PM

 
Hi Steve,

It looks like you don't have Axis Channel #4 configured to use Encoder #4 but rather Encoder #0.  Configure

ch4->InputChan0 = 4;

Then see if Axis Channel #4's position changes when the MPG moves.

If you are using Axis Channel #4 only for the MPG Encoder input functionality there is no need to enable the Axis.  The axis will still track the encoder position whether or not the Output is enabled.  Actually this is enabling axis #0 to axis #4's position.   So remove this:
Group: DynoMotion Message: 9901 From: Steve Klemp Date: 8/4/2014
Subject: Re: MPG smooth hardware
Hi Tom,  It was the enable bit (1055) Screw terminal was clamped on the wire insulation, giving me an intermittent signal. with that fixed the MPG is working
now.  
 Thanks For Your Help!
 
.....Steve
            
 


On Sunday, August 3, 2014 9:51 PM, "TK tk@... [DynoMotion]" <DynoMotion@yahoogroups.com> wrote:


 
Hi Steve,

Can you explain how you tested the input bits?  What were the states of all the inputs when you tested?

The Output Channels don't matter. We are not enabling axis 4 to output anything. We are only using the encoder input. 

This MPG code is just commanding one of the axis to move. So the axis to move must be configured, enabled, and capable to move. Are you able to move the axis without using the MPG?  Such as a MoveRel0=1000 on the Console Screen?

Regards
TK

On Aug 3, 2014, at 4:42 PM, "Steve Klemp steveklemp@... [DynoMotion]" <DynoMotion@yahoogroups.com> wrote:

 
Hi Tom,  I finally got a chance to work on my machine again.  I made the changes that you had sugestested. Now Axis Channel #4's position changes when the MPG moves. I do get all te defined switch inputs. I did verify that. I still cannot get an output (Axis) to move.  I am sure that I am missing something very basic but I cant see it. Here is my C program.
I am questioning this, 
ch4->OutputChan0=12;  is this suppose to be =12 ? 
 
#include "KMotionDef.h"
// Example Init program that includes "smooth" MPG motion example
// which makes use of the exponential motion command.
#define MPG_INPUT_AXIS 4
#define TAU 0.08 // smoothness factor (Low Pass Time constant seconds)
#define FINAL_TIME 1.0 // Set final dest after this amount of time with no change
#define ENABLE_MPG 1055
#define SELECTX 1048
#define SELECTY 1049
#define SELECTZ 1050
#define FACTOR1 1052
#define FACTOR10 1053
#define FACTOR100 1054
main()
{
     int Change1, NewPos, Pos;
     int InMotion=FALSE,Axis,LastAxis=-1;
     double LastChangeTime=0,Target,Factor=0;
 
     ch4->InputMode=ENCODER_MODE;
     ch4->OutputMode=CL_STEP_DIR_MODE;
     ch4->Vel=10000.000000;
     ch4->Accel=60000.000000;
     ch4->Jerk=10000000.000000;
     ch4->P=0.000000;
     ch4->I=0.015000;
     ch4->D=0.000000;
     ch4->FFAccel=0.000000;
     ch4->FFVel=0.000000;
     ch4->MaxI=200.000000;
     ch4->MaxErr=200.000000;
     ch4->M axOutput=2000.000000;
     ch4->DeadBandGain=1.000000;
     ch4->DeadBandRange=0.000000;
     ch4->InputChan0=4;
     ch4->InputChan1=0;
     ch4->OutputChan0=12;
     ch4->OutputChan1=0;
     ch4->LimitSwitchOptions=0x0;
     ch4->InputGain0=-2.500000;
     ch4->InputOffset0=0.000000;
     ch4->OutputGain=1.000000;
     ch4->OutputOffset=0.000000;
     ch4->SlaveGain=1.00000;
     ch4->Backl ashMode=BACKLASH_OFF;
     ch4->BacklashAmount=0.00000;
     ch4->BacklashRate=0.00000;
     ch4->invDistPerCycle=1.000000;
     ch4->Lead=0.000000;
     ch4->MaxFollowingError=100000.000000;
     ch4->StepperAmplitude=250.000000;
     ch4->iir[0].B0=1.000000;
     ch4->iir[0].B1=0.000000;
     ch4->iir[0].B2=0.000000;
     ch4->iir[0].A1=0.000000;
     ch4->iir[0].A2=0.000000;
     ch4->iir[1].B 0=1.000000;
     ch4->iir[1].B1=0.000000;
     ch4->iir[1].B2=0.000000;
     ch4->iir[1].A1=0.000000;
     ch4->iir[1].A2=0.000000;
     ch4->iir[2].B0=1.000000;
     ch4->iir[2].B1=0.000000;
     ch4->iir[2].B2=0.000000;
     ch4->iir[2].A1=0.000000;
     ch4->iir[2].A2=0.00000;
    
 
     DefineCoordSystem(0,1,2,-1);
 
     Pos = chan[MPG_INPUT_AXIS].Position;
     for (;;)
     {
          NewPos = chan[MPG_INPUT_AXIS].Position;
          Change1 = NewPos - Pos;
          Pos = NewPos;
          if (ReadBit(ENABLE_MPG)) // if button pressed ignore the encoder.
          Change1 = 0;
          else if (ReadBit(FACTOR1))  // is X1 selected?
          Factor = 2;
          else if (ReadBit(FACTOR10))  // is X10 selected?
          Factor = 20;
          else if (ReadBit(FACTOR100))  // is X100 selected?
          Factor = 200;
          else                   
          Factor = 0.0;
          if (ReadBit(SELECTX))  // is x selected?
          Axis=0;
          else if (ReadBit(SELECTY))  // is y selected?
          Axis=1;
          else if (ReadBit(SELECTZ))  // is z selected?
          Axis=2;
 
          // check if the Axis just changed or we have been 
          // converging to the target for a long time

          if (Axis != LastAxis || 
          (InMotion && Time_sec() > LastChangeTime+FINAL_TIME))
          
{
          if (InMotion)
          Move(LastAxis,Target);  //finalize any motion
 
          LastAxis = Axis;
          InMotion = FALSE;
          }
  
         if (Change1) // did we move?
         {
         if (!InMotion) Target = chan[Axis].Dest;
         Target += Change1 * Factor;
         MoveExp(Axis,Target,TAU);  // note: contains a WaitNextTimeSlice
         LastChangeTime = Time_sec();
         InMotion=TRUE;
         }
         else
        {
        WaitNextTimeSlice();
        }  
 } 
        return 0;
}
 
 
Looking forward to your response
.....Steve
            
 


On Sunday, July 27, 2014 6:36 PM, "Steve Klemp steveklemp@... [DynoMotion]" <DynoMotion@yahoogroups.com> wrote:


 
Tom, thank you for your time. I will give it a try and let you know what I find.
Thanks for all you do!

From: Tom Kerekes tk@... [DynoMotion] <DynoMotion@yahoogroups.com>;
To: DynoMotion@yahoogroups.com <DynoMotion@yahoogroups.com>;
Subject: Re: [DynoMotion] MPG smooth hardware
Sent: Sun, Jul 27, 2014 3:23:46 PM

 
Hi Steve,

It looks like you don't have Axis Channel #4 configured to use Encoder #4 but rather Encoder #0.  Configure

ch4->InputChan0 = 4;

Then see if Axis Channel #4's position changes when the MPG moves.

If you are using Axis Channel #4 only for the MPG Encoder input functionality there is no need to enable the Axis.  The axis will still track the encoder position whether or not the Output is enabled.  Actually this is enabling axis #0 to axis #4's position.   So remove this:


Group: DynoMotion Message: 9903 From: Tom Kerekes Date: 8/4/2014
Subject: Re: MPG smooth hardware
Hi Steve,

Thanks for posting back.

KFLOP now has a JOB_ACTIVE status that you may consider adding in place of or in conjunction with the MPG Enable input to avoid motion while a Job is running.

Regards
TK

Group: DynoMotion Message: 9904 From: Steve Klemp Date: 8/4/2014
Subject: Re: MPG smooth hardware
Hi Tom,
Thanks,  I will use JOB_ACTIVE status in conjunction with MPG Enable input.

Thanks again for all your help!
.....Steve
            
 


On Monday, August 4, 2014 9:59 AM, "Tom Kerekes tk@... [DynoMotion]" <DynoMotion@yahoogroups.com> wrote:


 
Hi Steve,

Thanks for posting back.

KFLOP now has a JOB_ACTIVE status that you may consider adding in place of or in conjunction with the MPG Enable input to avoid motion while a Job is running.

Regards
TK


From: "Steve Klemp steveklemp@... [DynoMotion]" <DynoMotion@yahoogroups.com>
To: "DynoMotion@yahoogroups.com" <DynoMotion@yahoogroups.com>
Sent: Monday, August 4, 2014 7:29 AM
Subject: Re: [DynoMotion] MPG smooth hardware

 
Hi Tom,  It was the enable bit (1055) Screw terminal was clamped on the wire insulation, giving me an intermittent signal. with that fixed the MPG is working
now.  
 Thanks For Your Help!
 
.....Steve
            
 


On Sunday, August 3, 2014 9:51 PM, "TK tk@... [DynoMotion]" <DynoMotion@yahoogroups.com> wrote:


 
Hi Steve,

Can you explain how you tested the input bits?  What were the states of all the inputs when you tested?

The Output Channels don't matter. We are not enabling axis 4 to output anything. We are only using the encoder input. 

This MPG code is just commanding one of the axis to move. So the axis to move must be configured, enabled, and capable to move. Are you able to move the axis without using the MPG?  Such as a MoveRel0=1000 on the Console Screen?

Regards
TK

On Aug 3, 2014, at 4:42 PM, "Steve Klemp steveklemp@... [DynoMotion]" <DynoMotion@yahoogroups.com> wrote:

 
Hi Tom,  I finally got a chance to work on my machine again.  I made the changes that you had sugestested. Now Axis Channel #4's position changes when the MPG moves. I do get all te defined switch inputs. I did verify that. I still cannot get an output (Axis) to move.  I am sure that I am missing something very basic but I cant see it. Here is my C program.
I am questioning this, 
ch4->OutputChan0=12;  is this suppose to be =12 ? 
 
#include "KMotionDef.h"
// Example Init program that includes "smooth" MPG motion example
// which makes use of the exponential motion command.
#define MPG_INPUT_AXIS 4
#define TAU 0.08 // smoothness factor (Low Pass Time constant seconds)
#define FINAL_TIME 1.0 // Set final dest after this amount of time with no change
#define ENABLE_MPG 1055
#define SELECTX 1048
#define SELECTY 1049
#define SELECTZ 1050
#define FACTOR1 1052
#define FACTOR10 1053
#define FACTOR100 1054
main()
{
     int Change1, NewPos, Pos;
     int InMotion=FALSE,Axis,LastAxis=-1;
     double LastChangeTime=0,Target,Factor=0;
 
     ch4->InputMode=ENCODER_MODE;
     ch4->OutputMode=CL_STEP_DIR_MODE;
     ch4->Vel=10000.000000;
     ch4->Accel=60000.000000;
     ch4->Jerk=10000000.000000;
     ch4->P=0.000000;
     ch4->I=0.015000;
     ch4->D=0.000000;
     ch4->FFAccel=0.000000;
     ch4->FFVel=0.000000;
     ch4->MaxI=200.000000;
     ch4->MaxErr=200.000000;
     ch4->M axOutput=2000.000000;
     ch4->DeadBandGain=1.000000;
     ch4->DeadBandRange=0.000000;
     ch4->InputChan0=4;
     ch4->InputChan1=0;
     ch4->OutputChan0=12;
     ch4->OutputChan1=0;
     ch4->LimitSwitchOptions=0x0;
     ch4->InputGain0=-2.500000;
     ch4->InputOffset0=0.000000;
     ch4->OutputGain=1.000000;
     ch4->OutputOffset=0.000000;
     ch4->SlaveGain=1.00000;
     ch4->Backl ashMode=BACKLASH_OFF;
     ch4->BacklashAmount=0.00000;
     ch4->BacklashRate=0.00000;
     ch4->invDistPerCycle=1.000000;
     ch4->Lead=0.000000;
     ch4->MaxFollowingError=100000.000000;
     ch4->StepperAmplitude=250.000000;
     ch4->iir[0].B0=1.000000;
     ch4->iir[0].B1=0.000000;
     ch4->iir[0].B2=0.000000;
     ch4->iir[0].A1=0.000000;
     ch4->iir[0].A2=0.000000;
     ch4->iir[1].B 0=1.000000;
     ch4->iir[1].B1=0.000000;
     ch4->iir[1].B2=0.000000;
     ch4->iir[1].A1=0.000000;
     ch4->iir[1].A2=0.000000;
     ch4->iir[2].B0=1.000000;
     ch4->iir[2].B1=0.000000;
     ch4->iir[2].B2=0.000000;
     ch4->iir[2].A1=0.000000;
     ch4->iir[2].A2=0.00000;
    
 
     DefineCoordSystem(0,1,2,-1);
 
     Pos = chan[MPG_INPUT_AXIS].Position;
     for (;;)
     {
          NewPos = chan[MPG_INPUT_AXIS].Position;
          Change1 = NewPos - Pos;
          Pos = NewPos;
          if (ReadBit(ENABLE_MPG)) // if button pressed ignore the encoder.
          Change1 = 0;
          else if (ReadBit(FACTOR1))  // is X1 selected?
          Factor = 2;
          else if (ReadBit(FACTOR10))  // is X10 selected?
          Factor = 20;
          else if (ReadBit(FACTOR100))  // is X100 selected?
          Factor = 200;
          else                   
          Factor = 0.0;
          if (ReadBit(SELECTX))  // is x selected?
          Axis=0;
          else if (ReadBit(SELECTY))  // is y selected?
          Axis=1;
          else if (ReadBit(SELECTZ))  // is z selected?
          Axis=2;
 
          // check if the Axis just changed or we have been 
          // converging to the target for a long time

          if (Axis != LastAxis || 
          (InMotion && Time_sec() > LastChangeTime+FINAL_TIME))
          
{
          if (InMotion)
          Move(LastAxis,Target);  //finalize any motion
 
          LastAxis = Axis;
          InMotion = FALSE;
          }
  
         if (Change1) // did we move?
         {
         if (!InMotion) Target = chan[Axis].Dest;
         Target += Change1 * Factor;
         MoveExp(Axis,Target,TAU);  // note: contains a WaitNextTimeSlice
         LastChangeTime = Time_sec();
         InMotion=TRUE;
         }
         else
        {
        WaitNextTimeSlice();
        }  
 } 
        return 0;
}
 
 
Looking forward to your response
.....Steve
            
 


On Sunday, July 27, 2014 6:36 PM, "Steve Klemp steveklemp@... [DynoMotion]" <DynoMotion@yahoogroups.com> wrote:


 
Tom, thank you for your time. I will give it a try and let you know what I find.
Thanks for all you do!

From: Tom Kerekes tk@... [DynoMotion] <DynoMotion@yahoogroups.com>;
To: DynoMotion@yahoogroups.com <DynoMotion@yahoogroups.com>;
Subject: Re: [DynoMotion] MPG smooth hardware
Sent: Sun, Jul 27, 2014 3:23:46 PM

 
Hi Steve,

It looks like you don't have Axis Channel #4 configured to use Encoder #4 but rather Encoder #0.  Configure

ch4->InputChan0 = 4;

Then see if Axis Channel #4's position changes when the MPG moves.

If you are using Axis Channel #4 only for the MPG Encoder input functionality there is no need to enable the Axis.  The axis will still track the encoder position whether or not the Output is enabled.  Actually this is enabling axis #0 to axis #4's position.   So remove this: